package cn.wolfcode.p2p.website.controller;

import cn.wolfcode.p2p.base.util.Constants;
import cn.wolfcode.p2p.bussness.query.BidRequestQueryObject;
import cn.wolfcode.p2p.bussness.service.IBidRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by wolfcode-lanxw
 */
@Controller
public class InvestController {
    @Autowired
    private IBidRequestService bidRequestService;
    @RequestMapping("invest")
    public String investPage(){
        return "invest";
    }
    @RequestMapping("invest_list")
    public String investList(BidRequestQueryObject qo, Model model){
        if(qo.getBidRequestState()==-1){
            qo.setStates(new int[]{Constants.BIDREQUEST_STATE_BIDDING, Constants.BIDREQUEST_STATE_PAYING_BACK, Constants.BIDREQUEST_STATE_COMPLETE_PAY_BACK});
        }
        model.addAttribute("pageInfo",bidRequestService.queryPage(qo));
        return "invest_list";
    }
}
